﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using llamaServer;

namespace llAma.Backend.Interface
{
    public class ClientEventArgs : EventArgs
    {
        private IConnection mClient;
        private string mDisconnectReason;
        public IConnection client
        {
            get { return mClient; }
            internal set { mClient = value; }
        }
        public string Reason
        {
            get { return mDisconnectReason; }
            internal set { mDisconnectReason = value; }
        }
        public bool IsDisconnecting
        {
            get { return !(string.IsNullOrEmpty(mDisconnectReason)); }
        }
        public ClientEventArgs(IConnection c)
        {
            mClient = c;
            mDisconnectReason = "";
        }
        public ClientEventArgs(IConnection c, string dcReason)
        {
            mClient = c;
            mDisconnectReason = dcReason;
        }
    }
    public interface IConnection : IHandlePackets
    {
        bool AddChannel(IChannel channel);
        bool RemoveChannel(IChannel channel);
        IChannel LookupChannel(string fullns);
        event EventHandler<ClientEventArgs> OnDisconnect;
        ConnectionState State
        {
            get;
            set;
        }
        bool CompatiblityMode
        {
            get;
        }
        IPAddress RemoteAddress
        {
            get;
        }
        IPAddress LocalAddress
        {
            get;
        }
        IPEndPoint RemoteEndPoint
        {
            get;
        }
        IPEndPoint LocalEndPoint
        {
            get;
        }
        int RemotePort
        {
            get;
        }
        int LocalPort
        {
            get;
        }
        bool Connected
        {
            get;
        }
        IUserData CurrentUser
        {
            get;
            set;
        }
        DateTime LoggedIn
        {
            get;
        }
        IChannel[] AllChannels
        {
            get;
        }
        DateTime LastPacket
        {
            get;
        }
        void Send(string data);
        string Agent
        {
            get;
        }
        Guid UUID
        { get; }
        string Username
        { get; }
        void Drop(string reason);
    }
}
